﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DSAManager.Core;
using DSAManager.Models.Input;
using DSAManager.Utils;

namespace DSAManager
{
    public partial class FrmChgPwd : Form
    {
        public FrmChgPwd()
        {
            InitializeComponent();
        }

        private void btn_save_Click(object sender, EventArgs e)
        {
            ChgPwdInfo chgPwdInfo=new ChgPwdInfo();
            chgPwdInfo.oldpassword = txt_oldpwd.Text;
            chgPwdInfo.newpassword = txt_newpwd.Text;
            chgPwdInfo.newpassword2 = txt_newpwd2.Text;
            var result = Api.ChangePassword(chgPwdInfo);
            if(result.ok)
                MsgBox.Alert("修改密码成功!");
            else
            {
                reset();
                MsgBox.Alert(result.msg);
            }
        }

        private void btn_reset_Click(object sender, EventArgs e)
        {
            reset();
        }

        void reset()
        {
            txt_newpwd.Clear();
            txt_newpwd2.Clear();
            txt_oldpwd.Clear();
        }
    }
}
